/*  KKS - KinoKassenSystem 2013
 * 
 *  author Sebastian Schöppner
 * 
 *  simplified version for adding components to the GridBagLayout
 * 
 *  
 */
package kks;

import java.awt.Component;
import java.awt.Container;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

public class LayoutHelper{
    
    /**
    * adds Component to GridBagLayout
    * <p>
    *
    * quelle: http://openbook.galileocomputing.de/javainsel9/javainsel_19_011.htm#mj3bf712331be49e8cbc1dae33786af8ac
    * 
    * @param  cont  container of the gridBagLayout
    * @param  gbl instance of the gridBBagLayout
    * @param  gbl location of the image, relative to the url argument
    * @param  c component to add to the layout
    * @param  x col in the layout
    * @param  y row in the layout
    * @param  width horizontal span over the layout
    * @param  height vertical span over the layout
    * @param  weightx
    * @param  weighty
    */
    
    public static void addComponent( Container cont, GridBagLayout gbl, Component c, int x, int y, int width, int height, double weightx, double weighty )
    {
      GridBagConstraints gbc = new GridBagConstraints();
      gbc.fill = GridBagConstraints.BOTH;
      gbc.gridx = x; 
      gbc.gridy = y;
      gbc.gridwidth = width; 
      gbc.gridheight = height;
      gbc.weightx = weightx; 
      gbc.weighty = weighty;
      gbl.setConstraints( c, gbc );
      cont.add( c );
    }

    /**
    * adds Component to GridBagLayout
    * <p>
    *
    * quelle: http://openbook.galileocomputing.de/javainsel9/javainsel_19_011.htm#mj3bf712331be49e8cbc1dae33786af8ac
    * 
    * @param  cont  container of the gridBagLayout
    * @param  gbl instance of the gridBBagLayout
    * @param  gbl location of the image, relative to the url argument
    * @param  c component to add to the layout
    * @param  x col in the layout
    * @param  y row in the layout
    * @param  width horizontal span over the layout
    * @param  height vertical span over the layout
    * @param  weightx
    * @param  weighty
    */
    
    public static void addComponent( Container cont, GridBagLayout gbl, Component c, int x, int y, int width, int height, double weightx, double weighty, int insets )
    {
      GridBagConstraints gbc = new GridBagConstraints();
      gbc.fill = GridBagConstraints.BOTH;
      gbc.gridx = x; 
      gbc.gridy = y;
      gbc.gridwidth = width; 
      gbc.gridheight = height;
      gbc.weightx = weightx; 
      gbc.weighty = weighty;
      gbc.insets = new Insets(insets, insets, insets, insets);
      gbl.setConstraints( c, gbc );
      cont.add( c );
    }
}
